//
//  Extension+NSString.swift
//  SHWeibo
//
//  Created by jingming wang on 16/8/1.
//  Copyright © 2016年 cpy.name. All rights reserved.
//

import UIKit

extension NSString {
    
    class func formatString(count: Int, string: String) -> String{
        // 如果count <= 0
        if count <= 0 {
            return string
        }else {
            // count > 0
            
            // 小于10000
            if count < 10000 {
                return "\(string)\(count)"
            }else {
                let cnt = CGFloat(count/1000)/10
                //  字符串拼接
                var countString = "\(cnt)万"
                // 如果字符串包含.0
                if countString.containsString(".0") {
                    // 字符串替换
                    countString = countString.stringByReplacingOccurrencesOfString(".0", withString: "")
                }
                
                return "\(string)\(countString)"
            }
        }
    }

}
